package cn.yunhe.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import cn.yunhe.entity.LoginUser;
import cn.yunhe.service.EssayService;

@ParentPackage("struts-default")
@ExceptionMappings({ @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") })
public class EssayAction extends BaseAction {
	private int essayid;
	private String title;
	private String content;
	private String picture;
	private LoginUser loginuser;

	// 添加
	@Action(value = "add", results = { @Result(name = "success", location = "/essaylist.jsp"),
			@Result(name = "error", location = "/error.jsp") })
	public String addessay() {
		EssayService es=new EssayService();
		Boolean flag=es.addEssay(title,content,picture,loginuser);
		if (flag) {
			return SUCCESS;
		}else {
			return ERROR;
		}
	}

	public int getEssayid() {
		return essayid;
	}

	public void setEssayid(int essayid) {
		this.essayid = essayid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public LoginUser getLoginuser() {
		return loginuser;
	}

	public void setLoginuser(LoginUser loginuser) {
		this.loginuser = loginuser;
	}

}
